package com.zhangxu.microservice.system.web.request;

import com.zhangxu.microservice.system.dao.enums.ResourceTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.List;

/**
 * 资源树请求
 */
@Data
@Schema(description = "资源树请求")
public class ResourceTreeReq {

    @Schema(description = "资源编码", example = "USER_MANAGE")
    @NotBlank(message = "资源编码不能为空")
    @Pattern(regexp = "^[A-Z_]+$", message = "资源编码只能包含大写字母和下划线")
    @Size(max = 255, message = "资源编码长度不能超过255个字符")
    private String code;

    @Schema(description = "资源名称", example = "用户管理")
    @NotBlank(message = "资源名称不能为空")
    @Size(max = 100, message = "资源名称长度不能超过100个字符")
    private String name;

    @Schema(description = "资源类型：DIRECTORY/MENU/BUTTON/API", example = "MENU")
    @NotNull(message = "资源类型不能为空")
    private ResourceTypeEnum type;

    @Schema(description = "前端路由路径或接口 URL", example = "/user/list")
    @Size(max = 512, message = "路径长度不能超过512个字符")
    private String path;

    @Schema(description = "请求方法", example = "GET")
    private String method;

    @Schema(description = "前端组件路径", example = "system/user/index")
    @Size(max = 255, message = "组件路径长度不能超过255个字符")
    private String component;

    @Schema(description = "子资源列表")
    @Valid
    private List<ResourceTreeReq> children;
}